﻿using System.Windows.Automation;

namespace QuickUIT.Controls
{
    /// <summary>
    /// Represents a button type control.  
    /// </summary>
    public class UIButton : UIBaseControl
    {
        /// <summary>
        /// Gets the current expand/collapse state of the button.
        /// If the control does not support the <see cref="ExpandCollapsePattern"/> , a null reference is returned.
        /// </summary>
        public new ExpandCollapseState? ExpandCollapseState
        {
            get { return base.ExpandCollapseState; }
        }

        /// <summary>
        /// Gets the current toggle state of the button.
        /// If the control does not support the <see cref="ToggleState"/> , a null reference is returned.
        /// </summary>
        public new ToggleState? ToggleState
        {
            get { return base.ToggleState; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class. 
        /// </summary>
        public UIButton() : base(ControlType.Button)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIButton(UIBaseControl parent) : base(parent, ControlType.Button)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIButton(string locator) : base(null, ControlType.Button, locator) 
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIButton(UIBaseControl parent, string locator) : base(parent, ControlType.Button, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIButton(AutomationElement control) : base(control, ControlType.Button)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIButton"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIButton(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.Button)
        {
        }

        /// <summary>
        /// Presses the button. 
        /// </summary>
        public void Press()
        {
            Invoke();
        }

        /// <summary>
        /// Toggles the button.  
        /// </summary>
        public new void Toggle()
        {
            base.Toggle();
        }

        /// <summary>
        /// Toggles the button on. 
        /// </summary>
        public new void ToggleOn()
        {
            base.ToggleOn();
        }

        /// <summary>
        /// Toggles the button off. 
        /// </summary>
        public new void ToggleOff()
        {
            base.ToggleOff();
        }

        /// <summary>
        /// Expands the button. 
        /// </summary>
        /// <remarks>If the button is something like a split button, this action may be supported.</remarks>
        public new void Expand()
        {
            base.Expand(); 
        }

        /// <summary>
        /// Collapses the button. 
        /// </summary>
        /// <remarks>If the button is something like a split button, this action may be supported.</remarks>
        public new void Collapse()
        {
            base.Collapse();
        }
    }
}
